package com.itheima.mm.mapper;

import com.github.pagehelper.Page;
import com.itheima.mm.dto.QuestionGetByIdDTO;
import com.itheima.mm.entity.QuestionPageQueryParams;
import com.itheima.mm.pojo.Question;
import com.itheima.mm.vo.QuestionMMVO;
import com.itheima.mm.vo.QuestionVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @Description QuestionMapper
 * @Author xiao
 * @Date 2024-06-25
 */
@Mapper
public interface QuestionMapper {

    /**预览试题
     * 根据id和是否精选查询题目数据
     * @param questionGetByIdDTO
     * @return
     */
    @Select("select (id+1000) number,t_question.* from t_question where id=#{id} and is_classic=#{isClassic}")
    QuestionVO getById(QuestionGetByIdDTO questionGetByIdDTO);


    //根据条件查一般试题
    Page<QuestionMMVO> findByCondition(QuestionPageQueryParams queryParams);



    //根据条件查精选试题
    List<QuestionMMVO> findByCondition2(QuestionPageQueryParams queryParams);





    //添加题目信息
    void add(Question question);



    //更新题目信息，也可用于更新精选is_classic
    void update(Question question);



    //删除题目信息
    @Delete("delete from t_question where id = #{questionId}")
    void deleteById(Integer questionId);

}
























